<?php
/**
 * upload.inc.php
 */

if(!defined('IN_SITE') || !defined('IN_ADMIN')) {
	exit('Access Denied');
}

require_once SITE_ROOT.'include/upload.class.php';

$dir = date('y').'/'.date('m');
$savePath = SITE_ROOT."attachments/".$dir;

if($dosubmit && $_FILES['uploadfile']['tmp_name'])
{
	$f = new upload("uploadfile", $savePath);
	$f->up();
	$img = $f->uploadedfiles;
	$uploadfilepath = $img[0]['filepath'];
	if($uploadfilepath && $oldfilepath)
	{
		@unlink(SITE_ROOT.'attachments'.$oldfilepath);
	}
	showmessage("文件上传成功！<script language='javascript'>	try{ window.opener.theform.".$inputid.".value='".$uploadfilepath."';}catch(e){} window.close();</script>");
}
else
{
	include admin_tpl("upload");
}
?>